<?php
if (!isset($nomarch)){
   $form1 = new psa_formulario;
   $form1->ejecuta ="index.php?psa_modulo=$psa_modulo";
   $form1->additem("Fecha ", 0);
   $form1->additem("", 1, "nomarch",date("d/m/Y"),"size=10");
   $form1->additem("", 3, "envia", "Consulta");
   $form1->muestra();
}else{
   $form1 = new psa_formulario;
   $form1->ejecuta ="";
   $form1->additem("Fecha ", 0);
   $form1->additem("", 1, "nomarch",$nomarch,"size=10");
   $form1->additem("", 3, "envia", "Consulta");
   $form1->muestra();

   $nomarch = substr($nomarch,6,4).substr($nomarch,3,2).substr($nomarch,0,2).".A35";

   $fp = fopen ("D:\genera\multibox10\datos\\".$nomarch,"r");
   $tab1 = new psa_tabla;
   $tab1->masfila(3);
   $tab1->dato( 1, "Tipo", "center");
   $tab1->dato( 2, "Nombre", "center");
   $tab1->dato( 3, "Hora", "center");

   while (($data = fgetcsv ($fp, 1000, " "))) {
      if ($data[0]=="0" or $data[0]=="1"){
         $tab1->masfila(3);
         if ($data[0]=="0"){
            $tab1->dato( 1, "Salida", "LEFT");
         }elseif ($data[0]=="0" or $data[0]=="1"){
            $tab1->dato( 1, "Entrada", "LEFT");
         }
         $tab1->dato( 2, nomtarj(intval($data[1])), "LEFT");
         $tab1->dato( 3, substr($data[3],0,2).":".substr($data[3],2,2), "center");
      }
   }
   $tab1->muestra();
   fclose ($fp);
}

function nomtarj($dato){
   $sSalida = "";
   include("inc/psa_conect.php");
   $sql = "select * from accesos where tarjeta=$dato";
   $result = mysql_query($sql,$link);
   if ($row = mysql_fetch_array($result)){
           $sSalida = $row["nombre"];

   }
   return($sSalida);
}
?>